package m_work;


import com.rabbitmq.client.Channel;
import com.rabbitmq.client.ConnectionFactory;


import java.io.IOException;
import java.util.Scanner;
import java.util.concurrent.TimeoutException;

public class Producer {
    public static void main(String[] args) throws IOException, TimeoutException {
        ConnectionFactory f=new ConnectionFactory();
        f.setHost("192.168.64.140");
        f.setPort(5672);
        f.setUsername("admin");
        f.setPassword("admin");
       //通道
        Channel ch =  f.newConnection().createChannel();
        //队列
        ch.queueDeclare("hellworld", //队列名
                false,              //是否是持久队列
                false,  //是否排他
                false,  //是否自动删除
                null);  //其他属性设置:需要构建一个对象
        while (true){
            System.out.println("输入信息");

                String mag =new Scanner(System.in).nextLine();
                ch.basicPublish("", //代表默认的
                        "hellworld",
                        null,//其他消息属性
                        mag.getBytes());  //发送的消息数据
        }


    }
}
